﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;

namespace JzSport.Api
{
    public static class ApiPageUtil
    {
        /// <summary>
        /// 获取当前用户的id，从url地址上的token参数上获取
        /// <para>例如：http://xxxxx.com/xxxx.aspx?sys:token=xxxxxxx</para>
        /// </summary>
        /// <returns>0:没有获取到id</returns>
        public static int GetCurrentUserId()
        {
            string token = HttpContext.Current.Request.QueryString["sys:token"];
            if (!string.IsNullOrEmpty(token))
            {
                try
                {
                    Api.Models.u uObj = Api.Models.UIDToken.FromToken(token);
                    if (uObj != null)
                    {
                        return uObj.a;
                    }
                }
                catch
                {

                }
                return 0;
            }
            return 0;
        }
    }
}
